import db.*;
import log.Logger;
import net.Connection;

import java.io.IOException;
import java.util.ArrayList;

/**
 * User: SLeeP
 * Date: 25.02.12
 * Time: 4:37
 */
public class Main {
    public static void main(String[] args) {
        new Logger(Logger.Mode.ACTION, "errors.log");
        Logger.write("PROGRAM STARTED", Logger.Mode.ACTION);
        try {
            DBConnection dbConnection = new DBConnection();
            int my_id = -1;
            System.out.println(my_id = dbConnection.login("ann", "ann"));
            //dbConnection.doSendMessage(my_id, 20, "test messagdmslgkadklg;adkgvfdmubiosbfhbldjgvaklsdmgklas;jklbjasdklgmasjl;vmdgslkbgjalskm;e 3");
            dbConnection.closeAccount(my_id, "2155106646541378", "");

//            Message message = dbConnection.getMessageByID(my_id, 1);
//            System.out.println(message.message);
//            ArrayList<Message> messages = dbConnection.doGetMessages(my_id, 0, 20);
//            System.out.println(messages.size());
//            System.out.println(dbConnection.doGetNumberOfUnreadMessages(my_id));
            //System.out.println(dbConnection.doSendMessage(my_id, 5, "test message"));
//            System.out.println(dbConnection.addUser(my_id, "megaserg", "12345", DBConnection.Role.CLIENT,"Sergey", "Serebryakov", "", 1, 16, 7, 1991, "Ptz", "11111", "in Ptz ", "2006-02-01", "Russia", "Spb", "Botanicheskaya 70/2 518", "12314", ""));
//            System.out.println(dbConnection.addAccount(my_id,my_id, DBConnection.OwnerType.CLIENT, 500, ""));
            //System.out.println(dbConnection.addAccount(my_id,190, DBConnection.OwnerType.CLIENT, ""));
//            System.out.println(dbConnection.doTransaction(my_id, "0008251425361762", "4883841856755640", 150, ""));
//            System.out.println(dbConnection.doPutMoney(my_id, "5437427586499617", 250, ""));
            /*System.out.println(dbConnection.logout(my_id));
            ArrayList<Account> list = dbConnection.getAccounts(my_id, 189, DBConnection.OwnerType.CLIENT);
            if (list != null) {
                for (Account a : list) {
                    a.print();
                }
            } else {
                System.out.println("null");
            }

            ArrayList<HistoryUnit> list2 = dbConnection.getAccountHistory(my_id, "9468076696460657", "2012-04-30", "2012-05-02");
            if (list2 != null) {
                for (HistoryUnit a : list2) {
                    a.print();
                }
            } else {
                System.out.println("null");
            }

            System.out.println(dbConnection.doPayForMobile(my_id, "9468076696460657", DBConnection.Mobile_Operator.MEGAFON, "9214617832", 650));
            */
        } catch (Exception e) {
            e.printStackTrace();
        }

        Logger.write("PROGRAM FINISHED", Logger.Mode.ACTION);
    }
}
